/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agtranscontinental.sisref.sessionbean;

import com.agtranscontinental.sisref.model.Configuraciones;
import com.agtranscontinental.sisref.sessionremote.ConfiguracionEjbRemote;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author ericson
 */
@Stateless
public class ConfiguracionEjbBean implements ConfiguracionEjbRemote {

    @PersistenceContext(unitName = "sisref_pu")
    private EntityManager emSisref;

    @Override
    public Configuraciones getConfiguracion(String tipo) {
        Configuraciones cfg = null;
        try {
            Query q = emSisref.createNamedQuery("Configuracion.byTpo");
            q.setParameter("tpo", tipo);
            cfg = (Configuraciones) q.getSingleResult();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return cfg;
    }
}
